  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

  <script>
  $(document).ready(function() {
    // Expander (used for collapsible code blocks)
    $('.expander-trigger').click(function(){
      $(this).toggleClass("expander-hidden");
    });
  });
  </script>

  <script>
    const BOKEH_CURRENT_VERSION = "{{ VERSION }}"
    $(document).ready(function () {
       $.getJSON('/versions.json', function (data) {
          if (BOKEH_CURRENT_VERSION != data.latest) {
            let msg
            if (data.all.indexOf(BOKEH_CURRENT_VERSION) < 0 ) {
              msg = "DEVELOPMENT / PRE-RELEASE"
            }
            else {
              msg = "PREVIOUS RELEASE"
            }
            content = $('<div class="version-alert">This page is documentation for a ' + msg + ' version. For the latest release, go to <a href="https://docs.bokeh.org/en/latest/">https://docs.bokeh.org/en/latest/</a></div>')
            $('#banner').append(content);
          }
          for (var i = 0; i < data.menu.length; i++) {
            const link = "https://docs.bokeh.org/en/" + data.menu[i]
            $('#version-menu').append('<a class="dropdown-item" href="' + link + '">' + data.menu[i] + '</a>')
          }
       })
    })
  </script>

  <script>
    $(document).ready(function () {
       $.get('/alert.html', function (data) {
          if (data.length > 0) {
            content = $('<div class="news-alert">' + data + '</div>')
            $('#banner').prepend(content);
          }
       })
    })
  </script>

  <script>
    // TOC sidebar - add "active" class to parent list
    //
    // Bootstrap's scrollspy adds the active class to the <a> link,
    // but for the automatic collapsing we need this on the parent list item.
    //
    // The event is triggered on "window" (and not the nav item as documented),
    // see https://github.com/twbs/bootstrap/issues/20086
    $(window).on("activate.bs.scrollspy", function(){
    var navLinks = document.querySelectorAll('#bd-toc-nav a');
    for (var i = 0; i < navLinks.length; i++) {
        var navLink = navLinks[i];
        navLink.parentElement.classList.remove('active');
    }
    var navLinks = document.querySelectorAll('#bd-toc-nav a.active');
    for (var i = 0; i < navLinks.length; i++) {
        var navLink = navLinks[i];
        navLink.parentElement.classList.add('active');
    }
    });
  </script>
